package com.csw.empGrey2.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.csw.empGrey2.dao.UserDao;
import com.csw.empGrey2.entity.User;

/**
 * @author 1
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;

	@Transactional(rollbackFor = Exception.class)
	@Override
	public User login(String username, String password) {
		return userDao.queryByUsernameAndPassword(username, password);
	}

	@Override
	public void addUser(User user) {
		userDao.addUser(user);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public User queryBy(String username) {
		return userDao.queryBy(username);
	}
}
